import java.util.Arrays;

public class Sort {
    //插入排序
    public static void insertSort(int[] array){
        for (int i = 1; i < array.length; i++) {
            int tmp = array[i];
            int j = i -1;
            for (; j >= 0; j++) {
                if(array[j]>tmp){
                    array[j] = tmp;
                }else{
                    array[j+1] = tmp;
                    break;
                }
            }
            array[j+1] =tmp;

        }
    }
    public static void main(String[] args) {
        int arr[] = {1,23,4,6,3,99,9};
        Sort.insertSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
